package com.bigshen.demo.project.service;

import com.bigshen.demo.project.common.MyApplicationContextAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Service;

import java.util.Arrays;

@Service
@DependsOn("myApplicationContext")
public class CommonService {

    @Autowired
    @Qualifier("myApplicationContext")
    private MyApplicationContextAware applicationContext;

    public void printlnAllBeanNames() {

        String[] allBeanNames = applicationContext.getApplicationContext().getBeanDefinitionNames();

        System.out.println(Arrays.toString(allBeanNames)
                .replaceAll("\\[", "")
                .replaceAll("\\]", "")
                .replaceAll(",", "\n"));

    }


}
